package com.maisonliberte.util;

import com.maisonliberte.entity.PriceInfo;

public class CalUtil {
	public static PriceInfo getPrice(int org_price, int localCarraige, int weight){
		float rate = RateUtil.getJapanRate() / 100;
		float fPrice = Float.MIN_VALUE;
		float fConPrice = Float.MIN_VALUE;
		int _price = 0;
		int _carrage = 0;
		int _conPrice = 0;
		int _comision = 0;
		if(weight > 0){
			// 送料＋価格＋手数料
			_price = org_price + localCarraige + getFowrdFee(weight);
			_carrage = getEmsFee(1, 1, weight);
			_conPrice = (org_price + localCarraige + getFowrdFee(weight));
		}else{
			int custWeight = 1500;
			_price = org_price + localCarraige + getFowrdFee(custWeight);
			_carrage = getEmsFee(1, 1, custWeight);
			_conPrice = (org_price + localCarraige + getFowrdFee(custWeight));
		}
		
		if(_price > 150000){
			_comision = 40000;
		}else if(_price > 30000){
			_comision = 30000;
		}else if(_price > 20000){
			_comision = 20000;
		}else if(_price > 10000){
			_comision = 15000;
		}else{
			_comision = 6000;
		}
		
		PriceInfo priceInfo = new PriceInfo();
		priceInfo.setRate(rate);
		priceInfo.setCommision(_comision);
		priceInfo.setOrgCarraige(localCarraige);
		priceInfo.setOrgPrice(org_price);
		priceInfo.setWeight(weight);
		priceInfo.setEmsFee(getEmsFee(1, 1, weight));
		priceInfo.setForwardFee(getFowrdFee(weight));
		
		return priceInfo;
	}
	
	private static int getFowrdFee(int weight){
		int [][] forward_fee = new int [11][2];

		forward_fee[0][0] = 500;
		forward_fee[0][1] = 490;
		forward_fee[1][0] = 1000;
		forward_fee[1][1] = 490;
		forward_fee[2][0] = 2000;
		forward_fee[2][1] = 980;
		forward_fee[3][0] = 3000;
		forward_fee[3][1] = 980;
		forward_fee[4][0] = 4000;
		forward_fee[4][1] = 1580;
		forward_fee[5][0] = 5000;
		forward_fee[5][1] = 1580;
		forward_fee[6][0] = 10000;
		forward_fee[6][1] = 1980;
		forward_fee[7][0] = 15000;
		forward_fee[7][1] = 2980;
		forward_fee[8][0] = 20000;
		forward_fee[8][1] = 2980;
		forward_fee[9][0] = 25000;
		forward_fee[9][1] = 3980;
		forward_fee[10][0] = 30000;
		forward_fee[10][1] = 3980;


		int weight_min = 0;

		for (int i = 0; i < forward_fee.length; i++) {
			int weight_max_int = forward_fee[i][0];
			int weight_int = weight;

			if (weight_min < weight_int && weight_int <= weight_max_int) {
				return forward_fee[i][1];
			}
			weight_min = weight_max_int;
		}
		
		return 0;		
	}
	
	private static int getEmsFee(int region_id_from, int region_id_to, int weight){
		
		int [][][][] ems_fee = new int[2][9][43][2];
		
		ems_fee[1][1][0][0] = 300;
		ems_fee[1][1][0][1] = 900;
		ems_fee[1][2][0][0] = 300;
		ems_fee[1][2][0][1] = 1200;
		ems_fee[1][3][0][0] = 300;
		ems_fee[1][3][0][1] = 1200;
		ems_fee[1][4][0][0] = 300;
		ems_fee[1][4][0][1] = 1200;
		ems_fee[1][5][0][0] = 300;
		ems_fee[1][5][0][1] = 1200;
		ems_fee[1][6][0][0] = 300;
		ems_fee[1][6][0][1] = 1500;
		ems_fee[1][7][0][0] = 300;
		ems_fee[1][7][0][1] = 1700;
		ems_fee[1][8][0][0] = 300;
		ems_fee[1][8][0][1] = 1700;
		ems_fee[1][1][1][0] = 500;
		ems_fee[1][1][1][1] = 1100;
		ems_fee[1][2][1][0] = 500;
		ems_fee[1][2][1][1] = 1500;
		ems_fee[1][3][1][0] = 500;
		ems_fee[1][3][1][1] = 1500;
		ems_fee[1][4][1][0] = 500;
		ems_fee[1][4][1][1] = 1500;
		ems_fee[1][5][1][0] = 500;
		ems_fee[1][5][1][1] = 1500;
		ems_fee[1][6][1][0] = 500;
		ems_fee[1][6][1][1] = 1800;
		ems_fee[1][7][1][0] = 500;
		ems_fee[1][7][1][1] = 2100;
		ems_fee[1][8][1][0] = 500;
		ems_fee[1][8][1][1] = 2100;
		ems_fee[1][1][2][0] = 600;
		ems_fee[1][1][2][1] = 1240;
		ems_fee[1][2][2][0] = 600;
		ems_fee[1][2][2][1] = 1680;
		ems_fee[1][3][2][0] = 600;
		ems_fee[1][3][2][1] = 1680;
		ems_fee[1][4][2][0] = 600;
		ems_fee[1][4][2][1] = 1680;
		ems_fee[1][5][2][0] = 600;
		ems_fee[1][5][2][1] = 1680;
		ems_fee[1][6][2][0] = 600;
		ems_fee[1][6][2][1] = 2000;
		ems_fee[1][7][2][0] = 600;
		ems_fee[1][7][2][1] = 2440;
		ems_fee[1][8][2][0] = 600;
		ems_fee[1][8][2][1] = 2440;
		ems_fee[1][1][3][0] = 700;
		ems_fee[1][1][3][1] = 1380;
		ems_fee[1][2][3][0] = 700;
		ems_fee[1][2][3][1] = 1860;
		ems_fee[1][3][3][0] = 700;
		ems_fee[1][3][3][1] = 1860;
		ems_fee[1][4][3][0] = 700;
		ems_fee[1][4][3][1] = 1860;
		ems_fee[1][5][3][0] = 700;
		ems_fee[1][5][3][1] = 1860;
		ems_fee[1][6][3][0] = 700;
		ems_fee[1][6][3][1] = 2200;
		ems_fee[1][7][3][0] = 700;
		ems_fee[1][7][3][1] = 2780;
		ems_fee[1][8][3][0] = 700;
		ems_fee[1][8][3][1] = 2780;
		ems_fee[1][1][4][0] = 800;
		ems_fee[1][1][4][1] = 1520;
		ems_fee[1][2][4][0] = 800;
		ems_fee[1][2][4][1] = 2040;
		ems_fee[1][3][4][0] = 800;
		ems_fee[1][3][4][1] = 2040;
		ems_fee[1][4][4][0] = 800;
		ems_fee[1][4][4][1] = 2040;
		ems_fee[1][5][4][0] = 800;
		ems_fee[1][5][4][1] = 2040;
		ems_fee[1][6][4][0] = 800;
		ems_fee[1][6][4][1] = 2400;
		ems_fee[1][7][4][0] = 800;
		ems_fee[1][7][4][1] = 3120;
		ems_fee[1][8][4][0] = 800;
		ems_fee[1][8][4][1] = 3120;
		ems_fee[1][1][5][0] = 900;
		ems_fee[1][1][5][1] = 1660;
		ems_fee[1][2][5][0] = 900;
		ems_fee[1][2][5][1] = 2220;
		ems_fee[1][3][5][0] = 900;
		ems_fee[1][3][5][1] = 2220;
		ems_fee[1][4][5][0] = 900;
		ems_fee[1][4][5][1] = 2220;
		ems_fee[1][5][5][0] = 900;
		ems_fee[1][5][5][1] = 2220;
		ems_fee[1][6][5][0] = 900;
		ems_fee[1][6][5][1] = 2600;
		ems_fee[1][7][5][0] = 900;
		ems_fee[1][7][5][1] = 3460;
		ems_fee[1][8][5][0] = 900;
		ems_fee[1][8][5][1] = 3460;
		ems_fee[1][1][6][0] = 1000;
		ems_fee[1][1][6][1] = 1800;
		ems_fee[1][2][6][0] = 1000;
		ems_fee[1][2][6][1] = 2400;
		ems_fee[1][3][6][0] = 1000;
		ems_fee[1][3][6][1] = 2400;
		ems_fee[1][4][6][0] = 1000;
		ems_fee[1][4][6][1] = 2400;
		ems_fee[1][5][6][0] = 1000;
		ems_fee[1][5][6][1] = 2400;
		ems_fee[1][6][6][0] = 1000;
		ems_fee[1][6][6][1] = 2800;
		ems_fee[1][7][6][0] = 1000;
		ems_fee[1][7][6][1] = 3800;
		ems_fee[1][8][6][0] = 1000;
		ems_fee[1][8][6][1] = 3800;
		ems_fee[1][1][7][0] = 1250;
		ems_fee[1][1][7][1] = 2100;
		ems_fee[1][2][7][0] = 1250;
		ems_fee[1][2][7][1] = 2800;
		ems_fee[1][3][7][0] = 1250;
		ems_fee[1][3][7][1] = 2800;
		ems_fee[1][4][7][0] = 1250;
		ems_fee[1][4][7][1] = 2800;
		ems_fee[1][5][7][0] = 1250;
		ems_fee[1][5][7][1] = 2800;
		ems_fee[1][6][7][0] = 1250;
		ems_fee[1][6][7][1] = 3250;
		ems_fee[1][7][7][0] = 1250;
		ems_fee[1][7][7][1] = 4600;
		ems_fee[1][8][7][0] = 1250;
		ems_fee[1][8][7][1] = 4600;
		ems_fee[1][1][8][0] = 1500;
		ems_fee[1][1][8][1] = 2400;
		ems_fee[1][2][8][0] = 1500;
		ems_fee[1][2][8][1] = 3200;
		ems_fee[1][3][8][0] = 1500;
		ems_fee[1][3][8][1] = 3200;
		ems_fee[1][4][8][0] = 1500;
		ems_fee[1][4][8][1] = 3200;
		ems_fee[1][5][8][0] = 1500;
		ems_fee[1][5][8][1] = 3200;
		ems_fee[1][6][8][0] = 1500;
		ems_fee[1][6][8][1] = 3700;
		ems_fee[1][7][8][0] = 1500;
		ems_fee[1][7][8][1] = 5400;
		ems_fee[1][8][8][0] = 1500;
		ems_fee[1][8][8][1] = 5400;
		ems_fee[1][1][9][0] = 1750;
		ems_fee[1][1][9][1] = 2700;
		ems_fee[1][2][9][0] = 1750;
		ems_fee[1][2][9][1] = 3600;
		ems_fee[1][3][9][0] = 1750;
		ems_fee[1][3][9][1] = 3600;
		ems_fee[1][4][9][0] = 1750;
		ems_fee[1][4][9][1] = 3600;
		ems_fee[1][5][9][0] = 1750;
		ems_fee[1][5][9][1] = 3600;
		ems_fee[1][6][9][0] = 1750;
		ems_fee[1][6][9][1] = 4150;
		ems_fee[1][7][9][0] = 1750;
		ems_fee[1][7][9][1] = 6200;
		ems_fee[1][8][9][0] = 1750;
		ems_fee[1][8][9][1] = 6200;
		ems_fee[1][1][10][0] = 2000;
		ems_fee[1][1][10][1] = 3000;
		ems_fee[1][2][10][0] = 2000;
		ems_fee[1][2][10][1] = 4000;
		ems_fee[1][3][10][0] = 2000;
		ems_fee[1][3][10][1] = 4000;
		ems_fee[1][4][10][0] = 2000;
		ems_fee[1][4][10][1] = 4000;
		ems_fee[1][5][10][0] = 2000;
		ems_fee[1][5][10][1] = 4000;
		ems_fee[1][6][10][0] = 2000;
		ems_fee[1][6][10][1] = 4600;
		ems_fee[1][7][10][0] = 2000;
		ems_fee[1][7][10][1] = 7000;
		ems_fee[1][8][10][0] = 2000;
		ems_fee[1][8][10][1] = 7000;
		ems_fee[1][1][11][0] = 2500;
		ems_fee[1][1][11][1] = 3500;
		ems_fee[1][2][11][0] = 2500;
		ems_fee[1][2][11][1] = 4700;
		ems_fee[1][3][11][0] = 2500;
		ems_fee[1][3][11][1] = 4700;
		ems_fee[1][4][11][0] = 2500;
		ems_fee[1][4][11][1] = 4700;
		ems_fee[1][5][11][0] = 2500;
		ems_fee[1][5][11][1] = 4700;
		ems_fee[1][6][11][0] = 2500;
		ems_fee[1][6][11][1] = 5400;
		ems_fee[1][7][11][0] = 2500;
		ems_fee[1][7][11][1] = 8500;
		ems_fee[1][8][11][0] = 2500;
		ems_fee[1][8][11][1] = 8500;
		ems_fee[1][1][12][0] = 3000;
		ems_fee[1][1][12][1] = 4000;
		ems_fee[1][2][12][0] = 3000;
		ems_fee[1][2][12][1] = 5400;
		ems_fee[1][3][12][0] = 3000;
		ems_fee[1][3][12][1] = 5400;
		ems_fee[1][4][12][0] = 3000;
		ems_fee[1][4][12][1] = 5400;
		ems_fee[1][5][12][0] = 3000;
		ems_fee[1][5][12][1] = 5400;
		ems_fee[1][6][12][0] = 3000;
		ems_fee[1][6][12][1] = 6200;
		ems_fee[1][7][12][0] = 3000;
		ems_fee[1][7][12][1] = 10000;
		ems_fee[1][8][12][0] = 3000;
		ems_fee[1][8][12][1] = 10000;
		ems_fee[1][1][13][0] = 3500;
		ems_fee[1][1][13][1] = 4500;
		ems_fee[1][2][13][0] = 3500;
		ems_fee[1][2][13][1] = 6100;
		ems_fee[1][3][13][0] = 3500;
		ems_fee[1][3][13][1] = 6100;
		ems_fee[1][4][13][0] = 3500;
		ems_fee[1][4][13][1] = 6100;
		ems_fee[1][5][13][0] = 3500;
		ems_fee[1][5][13][1] = 6100;
		ems_fee[1][6][13][0] = 3500;
		ems_fee[1][6][13][1] = 7000;
		ems_fee[1][7][13][0] = 3500;
		ems_fee[1][7][13][1] = 11500;
		ems_fee[1][8][13][0] = 3500;
		ems_fee[1][8][13][1] = 11500;
		ems_fee[1][1][14][0] = 4000;
		ems_fee[1][1][14][1] = 5000;
		ems_fee[1][2][14][0] = 4000;
		ems_fee[1][2][14][1] = 6800;
		ems_fee[1][3][14][0] = 4000;
		ems_fee[1][3][14][1] = 6800;
		ems_fee[1][4][14][0] = 4000;
		ems_fee[1][4][14][1] = 6800;
		ems_fee[1][5][14][0] = 4000;
		ems_fee[1][5][14][1] = 6800;
		ems_fee[1][6][14][0] = 4000;
		ems_fee[1][6][14][1] = 7800;
		ems_fee[1][7][14][0] = 4000;
		ems_fee[1][7][14][1] = 13000;
		ems_fee[1][8][14][0] = 4000;
		ems_fee[1][8][14][1] = 13000;
		ems_fee[1][1][15][0] = 4500;
		ems_fee[1][1][15][1] = 5500;
		ems_fee[1][2][15][0] = 4500;
		ems_fee[1][2][15][1] = 7500;
		ems_fee[1][3][15][0] = 4500;
		ems_fee[1][3][15][1] = 7500;
		ems_fee[1][4][15][0] = 4500;
		ems_fee[1][4][15][1] = 7500;
		ems_fee[1][5][15][0] = 4500;
		ems_fee[1][5][15][1] = 7500;
		ems_fee[1][6][15][0] = 4500;
		ems_fee[1][6][15][1] = 8600;
		ems_fee[1][7][15][0] = 4500;
		ems_fee[1][7][15][1] = 14500;
		ems_fee[1][8][15][0] = 4500;
		ems_fee[1][8][15][1] = 14500;
		ems_fee[1][1][16][0] = 5000;
		ems_fee[1][1][16][1] = 6000;
		ems_fee[1][2][16][0] = 5000;
		ems_fee[1][2][16][1] = 8200;
		ems_fee[1][3][16][0] = 5000;
		ems_fee[1][3][16][1] = 8200;
		ems_fee[1][4][16][0] = 5000;
		ems_fee[1][4][16][1] = 8200;
		ems_fee[1][5][16][0] = 5000;
		ems_fee[1][5][16][1] = 8200;
		ems_fee[1][6][16][0] = 5000;
		ems_fee[1][6][16][1] = 9400;
		ems_fee[1][7][16][0] = 5000;
		ems_fee[1][7][16][1] = 16000;
		ems_fee[1][8][16][0] = 5000;
		ems_fee[1][8][16][1] = 16000;
		ems_fee[1][1][17][0] = 5500;
		ems_fee[1][1][17][1] = 6500;
		ems_fee[1][2][17][0] = 5500;
		ems_fee[1][2][17][1] = 8900;
		ems_fee[1][3][17][0] = 5500;
		ems_fee[1][3][17][1] = 8900;
		ems_fee[1][4][17][0] = 5500;
		ems_fee[1][4][17][1] = 8900;
		ems_fee[1][5][17][0] = 5500;
		ems_fee[1][5][17][1] = 8900;
		ems_fee[1][6][17][0] = 5500;
		ems_fee[1][6][17][1] = 10200;
		ems_fee[1][7][17][0] = 5500;
		ems_fee[1][7][17][1] = 17500;
		ems_fee[1][8][17][0] = 5500;
		ems_fee[1][8][17][1] = 17500;
		ems_fee[1][1][18][0] = 6000;
		ems_fee[1][1][18][1] = 7000;
		ems_fee[1][2][18][0] = 6000;
		ems_fee[1][2][18][1] = 9600;
		ems_fee[1][3][18][0] = 6000;
		ems_fee[1][3][18][1] = 9600;
		ems_fee[1][4][18][0] = 6000;
		ems_fee[1][4][18][1] = 9600;
		ems_fee[1][5][18][0] = 6000;
		ems_fee[1][5][18][1] = 9600;
		ems_fee[1][6][18][0] = 6000;
		ems_fee[1][6][18][1] = 11000;
		ems_fee[1][7][18][0] = 6000;
		ems_fee[1][7][18][1] = 19000;
		ems_fee[1][8][18][0] = 6000;
		ems_fee[1][8][18][1] = 19000;
		ems_fee[1][1][19][0] = 7000;
		ems_fee[1][1][19][1] = 7800;
		ems_fee[1][2][19][0] = 7000;
		ems_fee[1][2][19][1] = 10700;
		ems_fee[1][3][19][0] = 7000;
		ems_fee[1][3][19][1] = 10700;
		ems_fee[1][4][19][0] = 7000;
		ems_fee[1][4][19][1] = 10700;
		ems_fee[1][5][19][0] = 7000;
		ems_fee[1][5][19][1] = 10700;
		ems_fee[1][6][19][0] = 7000;
		ems_fee[1][6][19][1] = 12300;
		ems_fee[1][7][19][0] = 7000;
		ems_fee[1][7][19][1] = 21100;
		ems_fee[1][8][19][0] = 7000;
		ems_fee[1][8][19][1] = 21100;
		ems_fee[1][1][20][0] = 8000;
		ems_fee[1][1][20][1] = 8600;
		ems_fee[1][2][20][0] = 8000;
		ems_fee[1][2][20][1] = 11800;
		ems_fee[1][3][20][0] = 8000;
		ems_fee[1][3][20][1] = 11800;
		ems_fee[1][4][20][0] = 8000;
		ems_fee[1][4][20][1] = 11800;
		ems_fee[1][5][20][0] = 8000;
		ems_fee[1][5][20][1] = 11800;
		ems_fee[1][6][20][0] = 8000;
		ems_fee[1][6][20][1] = 13600;
		ems_fee[1][7][20][0] = 8000;
		ems_fee[1][7][20][1] = 23200;
		ems_fee[1][8][20][0] = 8000;
		ems_fee[1][8][20][1] = 23200;
		ems_fee[1][1][21][0] = 9000;
		ems_fee[1][1][21][1] = 9400;
		ems_fee[1][2][21][0] = 9000;
		ems_fee[1][2][21][1] = 12900;
		ems_fee[1][3][21][0] = 9000;
		ems_fee[1][3][21][1] = 12900;
		ems_fee[1][4][21][0] = 9000;
		ems_fee[1][4][21][1] = 12900;
		ems_fee[1][5][21][0] = 9000;
		ems_fee[1][5][21][1] = 12900;
		ems_fee[1][6][21][0] = 9000;
		ems_fee[1][6][21][1] = 14900;
		ems_fee[1][7][21][0] = 9000;
		ems_fee[1][7][21][1] = 25300;
		ems_fee[1][8][21][0] = 9000;
		ems_fee[1][8][21][1] = 25300;
		ems_fee[1][1][22][0] = 10000;
		ems_fee[1][1][22][1] = 10200;
		ems_fee[1][2][22][0] = 10000;
		ems_fee[1][2][22][1] = 14000;
		ems_fee[1][3][22][0] = 10000;
		ems_fee[1][3][22][1] = 14000;
		ems_fee[1][4][22][0] = 10000;
		ems_fee[1][4][22][1] = 14000;
		ems_fee[1][5][22][0] = 10000;
		ems_fee[1][5][22][1] = 14000;
		ems_fee[1][6][22][0] = 10000;
		ems_fee[1][6][22][1] = 16200;
		ems_fee[1][7][22][0] = 10000;
		ems_fee[1][7][22][1] = 27400;
		ems_fee[1][8][22][0] = 10000;
		ems_fee[1][8][22][1] = 27400;
		ems_fee[1][1][23][0] = 11000;
		ems_fee[1][1][23][1] = 11000;
		ems_fee[1][2][23][0] = 11000;
		ems_fee[1][2][23][1] = 15100;
		ems_fee[1][3][23][0] = 11000;
		ems_fee[1][3][23][1] = 15100;
		ems_fee[1][4][23][0] = 11000;
		ems_fee[1][4][23][1] = 15100;
		ems_fee[1][5][23][0] = 11000;
		ems_fee[1][5][23][1] = 15100;
		ems_fee[1][6][23][0] = 11000;
		ems_fee[1][6][23][1] = 17500;
		ems_fee[1][7][23][0] = 11000;
		ems_fee[1][7][23][1] = 29500;
		ems_fee[1][8][23][0] = 11000;
		ems_fee[1][8][23][1] = 29500;
		ems_fee[1][1][24][0] = 12000;
		ems_fee[1][1][24][1] = 11800;
		ems_fee[1][2][24][0] = 12000;
		ems_fee[1][2][24][1] = 16200;
		ems_fee[1][3][24][0] = 12000;
		ems_fee[1][3][24][1] = 16200;
		ems_fee[1][4][24][0] = 12000;
		ems_fee[1][4][24][1] = 16200;
		ems_fee[1][5][24][0] = 12000;
		ems_fee[1][5][24][1] = 16200;
		ems_fee[1][6][24][0] = 12000;
		ems_fee[1][6][24][1] = 18800;
		ems_fee[1][7][24][0] = 12000;
		ems_fee[1][7][24][1] = 31600;
		ems_fee[1][8][24][0] = 12000;
		ems_fee[1][8][24][1] = 31600;
		ems_fee[1][1][25][0] = 13000;
		ems_fee[1][1][25][1] = 12600;
		ems_fee[1][2][25][0] = 13000;
		ems_fee[1][2][25][1] = 17300;
		ems_fee[1][3][25][0] = 13000;
		ems_fee[1][3][25][1] = 17300;
		ems_fee[1][4][25][0] = 13000;
		ems_fee[1][4][25][1] = 17300;
		ems_fee[1][5][25][0] = 13000;
		ems_fee[1][5][25][1] = 17300;
		ems_fee[1][6][25][0] = 13000;
		ems_fee[1][6][25][1] = 20100;
		ems_fee[1][7][25][0] = 13000;
		ems_fee[1][7][25][1] = 33700;
		ems_fee[1][8][25][0] = 13000;
		ems_fee[1][8][25][1] = 33700;
		ems_fee[1][1][26][0] = 14000;
		ems_fee[1][1][26][1] = 13400;
		ems_fee[1][2][26][0] = 14000;
		ems_fee[1][2][26][1] = 18400;
		ems_fee[1][3][26][0] = 14000;
		ems_fee[1][3][26][1] = 18400;
		ems_fee[1][4][26][0] = 14000;
		ems_fee[1][4][26][1] = 18400;
		ems_fee[1][5][26][0] = 14000;
		ems_fee[1][5][26][1] = 18400;
		ems_fee[1][6][26][0] = 14000;
		ems_fee[1][6][26][1] = 21400;
		ems_fee[1][7][26][0] = 14000;
		ems_fee[1][7][26][1] = 35800;
		ems_fee[1][8][26][0] = 14000;
		ems_fee[1][8][26][1] = 35800;
		ems_fee[1][1][27][0] = 15000;
		ems_fee[1][1][27][1] = 14200;
		ems_fee[1][2][27][0] = 15000;
		ems_fee[1][2][27][1] = 19500;
		ems_fee[1][3][27][0] = 15000;
		ems_fee[1][3][27][1] = 19500;
		ems_fee[1][4][27][0] = 15000;
		ems_fee[1][4][27][1] = 19500;
		ems_fee[1][5][27][0] = 15000;
		ems_fee[1][5][27][1] = 19500;
		ems_fee[1][6][27][0] = 15000;
		ems_fee[1][6][27][1] = 22700;
		ems_fee[1][7][27][0] = 15000;
		ems_fee[1][7][27][1] = 37900;
		ems_fee[1][8][27][0] = 15000;
		ems_fee[1][8][27][1] = 37900;
		ems_fee[1][1][28][0] = 16000;
		ems_fee[1][1][28][1] = 15000;
		ems_fee[1][2][28][0] = 16000;
		ems_fee[1][2][28][1] = 20600;
		ems_fee[1][3][28][0] = 16000;
		ems_fee[1][3][28][1] = 20600;
		ems_fee[1][4][28][0] = 16000;
		ems_fee[1][4][28][1] = 20600;
		ems_fee[1][5][28][0] = 16000;
		ems_fee[1][5][28][1] = 20600;
		ems_fee[1][6][28][0] = 16000;
		ems_fee[1][6][28][1] = 24000;
		ems_fee[1][7][28][0] = 16000;
		ems_fee[1][7][28][1] = 40000;
		ems_fee[1][8][28][0] = 16000;
		ems_fee[1][8][28][1] = 40000;
		ems_fee[1][1][29][0] = 17000;
		ems_fee[1][1][29][1] = 15800;
		ems_fee[1][2][29][0] = 17000;
		ems_fee[1][2][29][1] = 21700;
		ems_fee[1][3][29][0] = 17000;
		ems_fee[1][3][29][1] = 21700;
		ems_fee[1][4][29][0] = 17000;
		ems_fee[1][4][29][1] = 21700;
		ems_fee[1][5][29][0] = 17000;
		ems_fee[1][5][29][1] = 21700;
		ems_fee[1][6][29][0] = 17000;
		ems_fee[1][6][29][1] = 25300;
		ems_fee[1][7][29][0] = 17000;
		ems_fee[1][7][29][1] = 42100;
		ems_fee[1][8][29][0] = 17000;
		ems_fee[1][8][29][1] = 42100;
		ems_fee[1][1][30][0] = 18000;
		ems_fee[1][1][30][1] = 16600;
		ems_fee[1][2][30][0] = 18000;
		ems_fee[1][2][30][1] = 22800;
		ems_fee[1][3][30][0] = 18000;
		ems_fee[1][3][30][1] = 22800;
		ems_fee[1][4][30][0] = 18000;
		ems_fee[1][4][30][1] = 22800;
		ems_fee[1][5][30][0] = 18000;
		ems_fee[1][5][30][1] = 22800;
		ems_fee[1][6][30][0] = 18000;
		ems_fee[1][6][30][1] = 26600;
		ems_fee[1][7][30][0] = 18000;
		ems_fee[1][7][30][1] = 44200;
		ems_fee[1][8][30][0] = 18000;
		ems_fee[1][8][30][1] = 44200;
		ems_fee[1][1][31][0] = 19000;
		ems_fee[1][1][31][1] = 17400;
		ems_fee[1][2][31][0] = 19000;
		ems_fee[1][2][31][1] = 23900;
		ems_fee[1][3][31][0] = 19000;
		ems_fee[1][3][31][1] = 23900;
		ems_fee[1][4][31][0] = 19000;
		ems_fee[1][4][31][1] = 23900;
		ems_fee[1][5][31][0] = 19000;
		ems_fee[1][5][31][1] = 23900;
		ems_fee[1][6][31][0] = 19000;
		ems_fee[1][6][31][1] = 27900;
		ems_fee[1][7][31][0] = 19000;
		ems_fee[1][7][31][1] = 46300;
		ems_fee[1][8][31][0] = 19000;
		ems_fee[1][8][31][1] = 46300;
		ems_fee[1][1][32][0] = 20000;
		ems_fee[1][1][32][1] = 18200;
		ems_fee[1][2][32][0] = 20000;
		ems_fee[1][2][32][1] = 25000;
		ems_fee[1][3][32][0] = 20000;
		ems_fee[1][3][32][1] = 25000;
		ems_fee[1][4][32][0] = 20000;
		ems_fee[1][4][32][1] = 25000;
		ems_fee[1][5][32][0] = 20000;
		ems_fee[1][5][32][1] = 25000;
		ems_fee[1][6][32][0] = 20000;
		ems_fee[1][6][32][1] = 29200;
		ems_fee[1][7][32][0] = 20000;
		ems_fee[1][7][32][1] = 48400;
		ems_fee[1][8][32][0] = 20000;
		ems_fee[1][8][32][1] = 48400;
		ems_fee[1][1][33][0] = 21000;
		ems_fee[1][1][33][1] = 19000;
		ems_fee[1][2][33][0] = 21000;
		ems_fee[1][2][33][1] = 26100;
		ems_fee[1][3][33][0] = 21000;
		ems_fee[1][3][33][1] = 26100;
		ems_fee[1][4][33][0] = 21000;
		ems_fee[1][4][33][1] = 26100;
		ems_fee[1][5][33][0] = 21000;
		ems_fee[1][5][33][1] = 26100;
		ems_fee[1][6][33][0] = 21000;
		ems_fee[1][6][33][1] = 30500;
		ems_fee[1][7][33][0] = 21000;
		ems_fee[1][7][33][1] = 50500;
		ems_fee[1][8][33][0] = 21000;
		ems_fee[1][8][33][1] = 50500;
		ems_fee[1][1][34][0] = 22000;
		ems_fee[1][1][34][1] = 19800;
		ems_fee[1][2][34][0] = 22000;
		ems_fee[1][2][34][1] = 27200;
		ems_fee[1][3][34][0] = 22000;
		ems_fee[1][3][34][1] = 27200;
		ems_fee[1][4][34][0] = 22000;
		ems_fee[1][4][34][1] = 27200;
		ems_fee[1][5][34][0] = 22000;
		ems_fee[1][5][34][1] = 27200;
		ems_fee[1][6][34][0] = 22000;
		ems_fee[1][6][34][1] = 31800;
		ems_fee[1][7][34][0] = 22000;
		ems_fee[1][7][34][1] = 52600;
		ems_fee[1][8][34][0] = 22000;
		ems_fee[1][8][34][1] = 52600;
		ems_fee[1][1][35][0] = 23000;
		ems_fee[1][1][35][1] = 20600;
		ems_fee[1][2][35][0] = 23000;
		ems_fee[1][2][35][1] = 28300;
		ems_fee[1][3][35][0] = 23000;
		ems_fee[1][3][35][1] = 28300;
		ems_fee[1][4][35][0] = 23000;
		ems_fee[1][4][35][1] = 28300;
		ems_fee[1][5][35][0] = 23000;
		ems_fee[1][5][35][1] = 28300;
		ems_fee[1][6][35][0] = 23000;
		ems_fee[1][6][35][1] = 33100;
		ems_fee[1][7][35][0] = 23000;
		ems_fee[1][7][35][1] = 54700;
		ems_fee[1][8][35][0] = 23000;
		ems_fee[1][8][35][1] = 54700;
		ems_fee[1][1][36][0] = 24000;
		ems_fee[1][1][36][1] = 21400;
		ems_fee[1][2][36][0] = 24000;
		ems_fee[1][2][36][1] = 29400;
		ems_fee[1][3][36][0] = 24000;
		ems_fee[1][3][36][1] = 29400;
		ems_fee[1][4][36][0] = 24000;
		ems_fee[1][4][36][1] = 29400;
		ems_fee[1][5][36][0] = 24000;
		ems_fee[1][5][36][1] = 29400;
		ems_fee[1][6][36][0] = 24000;
		ems_fee[1][6][36][1] = 34400;
		ems_fee[1][7][36][0] = 24000;
		ems_fee[1][7][36][1] = 56800;
		ems_fee[1][8][36][0] = 24000;
		ems_fee[1][8][36][1] = 56800;
		ems_fee[1][1][37][0] = 25000;
		ems_fee[1][1][37][1] = 22200;
		ems_fee[1][2][37][0] = 25000;
		ems_fee[1][2][37][1] = 30500;
		ems_fee[1][3][37][0] = 25000;
		ems_fee[1][3][37][1] = 30500;
		ems_fee[1][4][37][0] = 25000;
		ems_fee[1][4][37][1] = 30500;
		ems_fee[1][5][37][0] = 25000;
		ems_fee[1][5][37][1] = 30500;
		ems_fee[1][6][37][0] = 25000;
		ems_fee[1][6][37][1] = 35700;
		ems_fee[1][7][37][0] = 25000;
		ems_fee[1][7][37][1] = 58900;
		ems_fee[1][8][37][0] = 25000;
		ems_fee[1][8][37][1] = 58900;
		ems_fee[1][1][38][0] = 26000;
		ems_fee[1][1][38][1] = 23000;
		ems_fee[1][2][38][0] = 26000;
		ems_fee[1][2][38][1] = 31600;
		ems_fee[1][3][38][0] = 26000;
		ems_fee[1][3][38][1] = 31600;
		ems_fee[1][4][38][0] = 26000;
		ems_fee[1][4][38][1] = 31600;
		ems_fee[1][5][38][0] = 26000;
		ems_fee[1][5][38][1] = 31600;
		ems_fee[1][6][38][0] = 26000;
		ems_fee[1][6][38][1] = 37000;
		ems_fee[1][7][38][0] = 26000;
		ems_fee[1][7][38][1] = 61000;
		ems_fee[1][8][38][0] = 26000;
		ems_fee[1][8][38][1] = 61000;
		ems_fee[1][1][39][0] = 27000;
		ems_fee[1][1][39][1] = 23800;
		ems_fee[1][2][39][0] = 27000;
		ems_fee[1][2][39][1] = 32700;
		ems_fee[1][3][39][0] = 27000;
		ems_fee[1][3][39][1] = 32700;
		ems_fee[1][4][39][0] = 27000;
		ems_fee[1][4][39][1] = 32700;
		ems_fee[1][5][39][0] = 27000;
		ems_fee[1][5][39][1] = 32700;
		ems_fee[1][6][39][0] = 27000;
		ems_fee[1][6][39][1] = 38300;
		ems_fee[1][7][39][0] = 27000;
		ems_fee[1][7][39][1] = 63100;
		ems_fee[1][8][39][0] = 27000;
		ems_fee[1][8][39][1] = 63100;
		ems_fee[1][1][40][0] = 28000;
		ems_fee[1][1][40][1] = 24600;
		ems_fee[1][2][40][0] = 28000;
		ems_fee[1][2][40][1] = 33800;
		ems_fee[1][3][40][0] = 28000;
		ems_fee[1][3][40][1] = 33800;
		ems_fee[1][4][40][0] = 28000;
		ems_fee[1][4][40][1] = 33800;
		ems_fee[1][5][40][0] = 28000;
		ems_fee[1][5][40][1] = 33800;
		ems_fee[1][6][40][0] = 28000;
		ems_fee[1][6][40][1] = 39600;
		ems_fee[1][7][40][0] = 28000;
		ems_fee[1][7][40][1] = 65200;
		ems_fee[1][8][40][0] = 28000;
		ems_fee[1][8][40][1] = 65200;
		ems_fee[1][1][41][0] = 29000;
		ems_fee[1][1][41][1] = 25400;
		ems_fee[1][2][41][0] = 29000;
		ems_fee[1][2][41][1] = 34900;
		ems_fee[1][3][41][0] = 29000;
		ems_fee[1][3][41][1] = 34900;
		ems_fee[1][4][41][0] = 29000;
		ems_fee[1][4][41][1] = 34900;
		ems_fee[1][5][41][0] = 29000;
		ems_fee[1][5][41][1] = 34900;
		ems_fee[1][6][41][0] = 29000;
		ems_fee[1][6][41][1] = 40900;
		ems_fee[1][7][41][0] = 29000;
		ems_fee[1][7][41][1] = 67300;
		ems_fee[1][8][41][0] = 29000;
		ems_fee[1][8][41][1] = 67300;
		ems_fee[1][1][42][0] = 30000;
		ems_fee[1][1][42][1] = 26200;
		ems_fee[1][2][42][0] = 30000;
		ems_fee[1][2][42][1] = 36000;
		ems_fee[1][3][42][0] = 30000;
		ems_fee[1][3][42][1] = 36000;
		ems_fee[1][4][42][0] = 30000;
		ems_fee[1][4][42][1] = 36000;
		ems_fee[1][5][42][0] = 30000;
		ems_fee[1][5][42][1] = 36000;
		ems_fee[1][6][42][0] = 30000;
		ems_fee[1][6][42][1] = 42200;
		ems_fee[1][7][42][0] = 30000;
		ems_fee[1][7][42][1] = 69400;
		ems_fee[1][8][42][0] = 30000;
		ems_fee[1][8][42][1] = 69400;
		
		int weight_min = 0;
		
		for (int i = 0; i < ems_fee[region_id_from][region_id_to].length; i++) {
			int weight_max_int = ems_fee[region_id_from][region_id_to][i][0];
			int weight_int = weight;

			if (weight_min < weight_int && weight_int <= weight_max_int) {
				return ems_fee[region_id_from][region_id_to][i][1];
			}
			weight_min = weight_max_int;
		}
		return 0;
	}
}
